package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 水电承担方
 *
 * @Author Feng
 * @date 2023/7/3
 */
@Getter
@AllArgsConstructor
public enum HydropowerShareMethodEnum {
    BUSINESS_BEARS_ALL_THE_COSTS(1, "企业"),
    ENTERPRISE_ONLY_BEARS_THE_RENT_DEPOSIT(2, "寝室长");
    private Integer code;
    private String msg;


    public static String getMsgByCode(Integer code) {
        if (code == null) {
            return "";
        }
        Optional<String> first = Arrays.stream(HydropowerShareMethodEnum.values()).filter(s -> s.getCode().equals(code)).map(s -> s.getMsg()).findFirst();
        if (first.isPresent()) {
            return first.get();
        }
        return "";
    }
}
